// 缓存相关类型定义

export interface CacheOptions {
  ttl?: number;
  tags?: string[];
  compress?: boolean;
  serialize?: boolean;
}

export interface CacheEntry<T = any> {
  value: T;
  createdAt: Date;
  expiresAt: Date | undefined;
  tags: string[];
  hits: number;
  size: number;
}

export interface CacheStats {
  hits: number;
  misses: number;
  hitRate: number;
  totalKeys: number;
  totalMemory: number;
  averageKeySize: number;
}

export interface TaggedCacheEntry<T = any> extends CacheEntry<T> {
  tags: string[];
}

export interface CacheInvalidationResult {
  invalidatedKeys: string[];
  totalInvalidated: number;
  errors: Array<{
    key: string;
    error: Error;
  }>;
}

export interface CachePattern {
  pattern: string;
  ttl?: number;
  tags?: string[];
  compress?: boolean;
}

export interface CacheMetrics {
  operations: {
    get: number;
    set: number;
    delete: number;
    invalidate: number;
  };
  performance: {
    averageGetTime: number;
    averageSetTime: number;
    slowestOperation: {
      operation: string;
      duration: number;
      key: string;
    };
  };
  memory: {
    totalUsed: number;
    keyCount: number;
    averageKeySize: number;
    largestKey: {
      key: string;
      size: number;
    };
  };
}
